#include <iostream>
#include <ctime>
#include <fstream>
using namespace std;
void bubl(int list[], int listlen){
    while(listlen--){
        bool swapped = false;
        for(int i = 0; i < listlen; i++){
            if(list[i] > list[i+1]){
                swap(list[i], list[i+1]);
                swapped = true;
            }
        }
        if(swapped == false) break;
    }
}
void rff(const char *filename, int a[], int len){
    ifstream file(filename);
    for(int i = 0; i<len; i++)
        file >> a[i];
}
int main()
{
    const int LEN = 5000;
    int a[LEN];
    int b[LEN];
    int c[LEN];
    rff("m1_sorted.txt", a, LEN);
    unsigned int t_start = clock();
    bubl(a, LEN);
    unsigned int t_finish = clock();
    cout << "m1 sorted " << t_finish - t_start << " miliseconds" << endl;
    rff("m2_reverse.txt", b, LEN);
    unsigned int t_start1 = clock();
    bubl(a, LEN);
    unsigned int t_finish1 = clock();
    cout << "m2 sorted " << t_finish1 - t_start1 << " miliseconds" << endl;
    rff("m3_shuffle.txt", c, LEN);
    unsigned int t_start2 = clock();
    bubl(a, LEN);
    unsigned int t_finish2 = clock();
    cout << "m3 sorted " << t_finish2 - t_start2 << " miliseconds" << endl;
}
